package com.zy.test.store;

import android.widget.Toast;

import androidx.annotation.NonNull;

import com.zy.activity.BaseMenuActivity;
import com.zy.activity.bean.BaseMenuBean;
import com.zy.storage.mmkv.MMKVManager;

import java.util.ArrayList;
import java.util.List;

public class MMKVDemoActivity extends BaseMenuActivity {

    private final String TAG = "StoreActivity";

    @Override
    protected void init(@NonNull ArrayList<BaseMenuBean> list) {
        list.add(new BaseMenuBean("MMKV"));
        //https://github.com/Tencent/MMKV/wiki/android_tutorial_cn
        list.add(new BaseMenuBean("使用教程"));
        list.add(new BaseMenuBean("初始化", 1));
        list.add(new BaseMenuBean("添加", 2));
        list.add(new BaseMenuBean("删除", 3));
        list.add(new BaseMenuBean("多进程", 4));
        list.add(new BaseMenuBean("业务ID", 5));

        //https://github.com/Tencent/MMKV/wiki/android_advance_cn
        list.add(new BaseMenuBean("进阶教程"));
        list.add(new BaseMenuBean("日志", 6));
        list.add(new BaseMenuBean("日志开关", 7));
        list.add(new BaseMenuBean("加密", 8));
        list.add(new BaseMenuBean("更改密钥", 9));
        list.add(new BaseMenuBean("自定义根目录", 10));
        list.add(new BaseMenuBean("自定义根目录02", 11));
    }

    @Override
    protected void clickItem(BaseMenuBean bean) {
        if (bean.getCode() == 1) {
            MMKVManager.getInstance().init(this);
        } else if (bean.getCode() == 2) {
            MMKVManager.getInstance().testAdd();
        } else if (bean.getCode() == 3) {
            MMKVManager.getInstance().testRemove();
        } else if (bean.getCode() == 4) {
            MMKVManager.getInstance().testMultiProcessDode();
        } else if (bean.getCode() == 5) {
            MMKVManager.getInstance().testID();
        } else if (bean.getCode() == 6) {
            MMKVManager.getInstance().testLogcat();
        } else if (bean.getCode() == 7) {
            MMKVManager.getInstance().testLogcatEnable();
        } else if (bean.getCode() == 8) {
            MMKVManager.getInstance().testEncrypt();
        } else if (bean.getCode() == 9) {
            MMKVManager.getInstance().testEncryptOpt1();
        } else if (bean.getCode() == 10) {
            MMKVManager.getInstance().testDIYRoot(this);
        } else if (bean.getCode() == 11) {
            MMKVManager.getInstance().testDIYRoot02(this);
        } else {
            Toast.makeText(this, "待更新", Toast.LENGTH_LONG).show();
        }
    }
}